<template>
  <el-dialog
    :title="'详情'"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-form :model="dataForm" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="100px">
      <el-form-item label="工夹具代码" prop="code">
        <el-input disabled v-model="dataForm.code" placeholder="工夹具代码"></el-input>
      </el-form-item>
      <el-form-item label="工夹具名称" prop="name">
        <el-input disabled v-model="dataForm.name" placeholder="工夹具名称"></el-input>
      </el-form-item>
      <el-form-item label="所属部门" prop="workcell">
        <el-input disabled v-model="dataForm.workcell" placeholder="所属工作部，外键，参照工作部门表"></el-input>
      </el-form-item>
      <el-form-item label="类别" prop="family">
        <el-input disabled v-model="dataForm.family" placeholder="类别"></el-input>
      </el-form-item>
      <el-form-item label="工夹具模组" prop="model">
        <el-input disabled v-model="dataForm.model" placeholder="工夹具模组，多个用“|”分割"></el-input>
      </el-form-item>
      <el-form-item label="料号" prop="partNo">
        <el-input disabled v-model="dataForm.partNo" placeholder="工夹具料号，多个用“|”分割"></el-input>
      </el-form-item>
      <el-form-item label="用途" prop="userFor">
        <el-input disabled v-model="dataForm.userFor" placeholder="用途"></el-input>
      </el-form-item>
      <el-form-item label="每条产线所需" prop="upl">
        <el-input disabled v-model="dataForm.upl" placeholder="每条产线上需要配备的数量"></el-input>
      </el-form-item>
      <el-form-item label="责任人" prop="owner">
        <el-input disabled v-model="dataForm.owner" placeholder="责任人"></el-input>
      </el-form-item>
      <el-form-item label="录入人" prop="recBy">
        <el-input disabled v-model="dataForm.recBy" placeholder="录入人"></el-input>
      </el-form-item>
      <el-form-item label="录入时间" prop="recTime">
        <el-input disabled v-model="dataForm.recTime" placeholder="录入时间"></el-input>
      </el-form-item>
      <el-form-item label="修改人" prop="editBy">
        <el-input disabled v-model="dataForm.editBy" placeholder="修改人"></el-input>
      </el-form-item>
      <el-form-item label="修改时间" prop="editTime">
        <el-input disabled v-model="dataForm.editTime" placeholder="修改时间"></el-input>
      </el-form-item>
      <el-form-item label="保养点检周期" prop="pmPeriod">
        <el-input disabled v-model="dataForm.pmPeriod" placeholder="保养点检周期"></el-input>
      </el-form-item>
      <el-form-item label="备注" prop="remark">
        <el-input disabled v-model="dataForm.remark" placeholder="备注"></el-input>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  data () {
    return {
      visible: false,
      dataForm: {
        id: 0,
        family: ''
      },

    }
  },
  methods: {
    init (id) {
      console.log("----"+id)
      this.dataForm.id = id
      this.visible = true
      this.$nextTick(() => {
        this.$refs['dataForm'].resetFields()
        if (this.dataForm.id) {
          this.$http({
            url:`http://localhost:10000/gongjiajumain/jigdefinition/info/${this.dataForm.id}`,
            method: 'get'
          }).then(({data}) => {
            console.log(data)
            // if (data && data.code === 0) {
            this.dataForm = data.jigDefinition
            // }
          })
        }
      })
    },
    // 表单提交
    // dataFormSubmit () {
    //   this.$refs['dataForm'].validate((valid) => {
    //     if (valid) {
    //       this.$http({
    //         url: this.$http.adornUrl(`/gongjiajumain/jigfamily/${!this.dataForm.id ? 'save' : 'update'}`),
    //         method: 'post',
    //         data: this.$http.adornData({
    //           'id': this.dataForm.id || undefined,
    //           'family': this.dataForm.family
    //         })
    //       }).then(({data}) => {
    //         if (data && data.code === 0) {
    //           this.$message({
    //             message: '操作成功',
    //             type: 'success',
    //             duration: 1500,
    //             onClose: () => {
    //               this.visible = false
    //               this.$emit('refreshDataList')
    //             }
    //           })
    //         } else {
    //           this.$message.error(data.msg)
    //         }
    //       })
    //     }
    //   })
    // }
  }
}
</script>
